package com.kehutong.flow.admin;

import org.coraframework.authz.HasPermission;
import org.coraframework.inject.Inject;
import org.coraframework.json.JSONObject;
import org.coraframework.mvc.MvcAction;
import org.coraframework.mvc.http.Bean;
import org.coraframework.mvc.http.ReqMapping;
import org.coraframework.mvc.http.result.Result;
import org.coraframework.orm.jdbc.JdbcSession;

import com.kehutong.flow.entity.FlowRole;
import com.kehutong.flow.service.FlowRoleService;

@MvcAction
@ReqMapping("/admin/flow/role")
public class FlowRoleController {

    @Inject
    private JdbcSession jdbcSession;

    @Inject
    private FlowRoleService flowRoleService;

    @HasPermission("flow:role:view")
    @ReqMapping("/list")
    public Object list(JSONObject jsonObject) {
        return Result.success(flowRoleService.list(jsonObject));
    }

    @HasPermission("flow:role:view")
    @ReqMapping("/get")
    public Object get(String id) {
        return Result.success(flowRoleService.get(id));
    }

    @Bean(newInstance=true, copy=true)
    @HasPermission("flow:role:edit")
    @ReqMapping("/save")
    public Object save(FlowRole item) {
        return flowRoleService.save(item);
    }

    @Bean(copy=true)
    @HasPermission("flow:role:edit")
    @ReqMapping("/update")
    public Object update(FlowRole item) {
        return flowRoleService.update(item);
    }

    @HasPermission("flow:role:edit")
    @ReqMapping("/delete")
    public Object delete(String id) {
        return flowRoleService.delete(id);
    }

}
